package hz.mobileproject.pda.model.attendancemanager.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.toolsmanager.adapter.ToolsMainGVAdapter;
import hz.mobileproject.pda.toolsmanager.bean.Item_ToolsMain;
import hz.mobileproject.pda.ui.base.BaseActivity;

@ContentView(R.layout.activity_attendance_main)
public class AttendanceMainActivity extends BaseActivity {
    @ViewInject(R.id.gv_attendance_manager)
    private GridView gv_attendance_manager;

    @Override
    protected void initData() {
        List<Item_ToolsMain> mainItemList = new ArrayList<>();
        mainItemList.add(new Item_ToolsMain("外出报备", R.mipmap.icon_waichubaobei));
        mainItemList.add(new Item_ToolsMain("请销假", R.mipmap.icon_qingjia));
        mainItemList.add(new Item_ToolsMain("出国申请", R.mipmap.icon_chuguoshenpi));
        mainItemList.add(new Item_ToolsMain("排班信息", R.mipmap.icon_paibanxinxi));
        mainItemList.add(new Item_ToolsMain("考勤信息", R.mipmap.icon_kaoqinxinxi));
        ToolsMainGVAdapter adapter = new ToolsMainGVAdapter(this, mainItemList);
        gv_attendance_manager.setAdapter(adapter);
        gv_attendance_manager.setOnItemClickListener(onItemClickListener);
    }

    /**
     * 主页菜单点击事件
     */
    private AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent = new Intent();
            switch (i) {
                case 0://外出报备
                    intent.setClass(AttendanceMainActivity.this, OutgoingActivity.class);
                    startActivity(intent);
                    break;
                case 1://请销假
                    intent.setClass(AttendanceMainActivity.this, LeaveActivity.class);
                    startActivity(intent);
                    break;
                case 2://出国申请
                    intent.setClass(AttendanceMainActivity.this, GoAbroadActivity.class);
                    startActivity(intent);
                    break;
                case 3://排班信息
                    intent.setClass(AttendanceMainActivity.this, SchedulingMsgActivity.class);
                    startActivity(intent);
                    break;
                case 4://考勤信息
                    intent.setClass(AttendanceMainActivity.this, AttendanceMsgActivity.class);
                    startActivity(intent);
                    break;
            }
        }
    };
}
